﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace FUSE
{
    class Planet : GalaxyComponent,FUSE.IMassedComponent
    {
        string name;        //planet name

        Circle crashCircle;
        Circle slingCircle;


        int mass;

        int points;         //the number of points recieved for a successful orbit of the planet (also used to determine slingshot points)
                
        Texture2D planetImage;  //the image
        Rectangle source;       //the source for the image

        Vector2 topLeftPosition = new Vector2();       //the position of the planet

        public int crashRadius;        //the radius (in pixels) in which the user would crash into the planet
        public int orbitRadius;        //the radius (in pixels) in which the user would orbit the planet
        public int slingRadius;        //the radius (in pixels) in which the user would slingshot around the planet
        //consider implementing a circle
        int magicFormula;

        public void Create()
        {
            throw new NotImplementedException();
        }


        public Planet()
        {
            
            name = nameGen();
            mass = 0;
            points = 0;
            crashRadius = 0;
            orbitRadius = 0;
            magicFormula = 0;
        }


        public void Initialize(int newMass, int newPoints, Texture2D newImage, Rectangle imageSource, Vector2 newPosition)
        {
            mass = newMass;             //set mass to loaded mass
            points = newPoints;         //set planetary score points to loaded points
            planetImage = newImage;     //set the image of the planet to the loaded image
            source = imageSource;       //set the source of the image to the loaded source
            topLeftPosition = newPosition;     //set the planetary position to the loaded position

            Vector2 center = new Vector2(topLeftPosition.X / 2, topLeftPosition.Y/ 2); //the center of the planet

            crashRadius =(int) (mass * .5f); //all three radii will be calculated based on formula involving planetary mass and size (source.Height)
            orbitRadius = (int)(mass * 1f);
            slingRadius = (int)(mass * 1.5f);
        }

        private string nameGen()
        {
            string newName;
            //make random name generator, thinking consonant-vowel-consonant-vowel-consonant-consonant-vowel, random numbers 0-19 = consonant 20-25 = vowel
            Random numGen = new Random();
            newName = "SUPER PLANET";
            numGen.Next(26);
            //var vowels = new Array("a", "e", "i", "o", "u");
            //var consts = new Array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "x", "z");




            return newName;
        }

        public Circle CrashCircle
        {
            get { return crashCircle; }
            set { crashCircle = value; }
        }

        public Circle SlingCircle
        {
            get { return slingCircle; }
            set { slingCircle = value; }
        }

        public int Mass
        {
            get { return mass; }
        }
    }
}
